package com.suoluo.zenapp.common;

import javax.servlet.http.HttpServletRequest;

public final class PathUtil {

	private PathUtil() {

	}

	/**
	 * 获取真实路径
	 * 
	 * @param request
	 *            请求
	 * @param path
	 *            指定的子路径，eg:images
	 * @return String 返回服务器下的
	 */
	public static String getRealPath(HttpServletRequest request, String path) {
		String realPath = request.getSession().getServletContext()
				.getRealPath("/" + path);

		if (path.endsWith("/")) {
			realPath += "/";
		}
		return realPath;
	}

	// public static void main(String []args)
	// {
	// String path = "aaaa/";
	// System.out.println(path.endsWith("/"));
	// }
}
